package Form; 
import java.*;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JScrollPane;
import javax.swing.JLayeredPane;
import javax.swing.JToolBar;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JList;
import javax.swing.ListSelectionModel;
import javax.swing.JRadioButton;
import javax.swing.JComboBox;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.text.JTextComponent;

import Control.CommonControls;
import Control.Job_Registration_Controller;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;

public class Job_RegistrationForm extends JPanel{
	private JTextField jobName;
	private JComboBox edu_comboBox;
	private JLabel lblSalary;
	private JLabel lblNewLabel_3;
	private JLabel lblNewLabel_4;
	private JComboBox category_Combo;
	private JLabel label;
	private JLabel lblJobStatus;
	private JComboBox statusCombo;
	private JButton job_Submit;
	private JButton job_Cancel;
	Job_Registration_Controller Controller;
	private JTextField jobDesc;
	private JTextField employerID;
	private JSpinner salarySpinner;
	private JSpinner noOfSlots;
	public Job_RegistrationForm() {
		Controller = new Job_Registration_Controller(this);
		
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{72, 90, 170, 125, 0, 0, 0};
		gridBagLayout.rowHeights = new int[]{45, 32, 45, 32, 22, 25, 0, 0, 0, 0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JLabel lblNewLabel = new JLabel("Register Job");
		lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
		gbc_lblNewLabel.fill = GridBagConstraints.VERTICAL;
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel.gridwidth = 2;
		gbc_lblNewLabel.gridx = 2;
		gbc_lblNewLabel.gridy = 0;
		add(lblNewLabel, gbc_lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("Job Name:");
		lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
		GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
		gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_1.fill = GridBagConstraints.VERTICAL;
		gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_1.gridx = 1;
		gbc_lblNewLabel_1.gridy = 1;
		add(lblNewLabel_1, gbc_lblNewLabel_1);
		
		jobName = new JTextField();
		GridBagConstraints gbc_jobName = new GridBagConstraints();
		gbc_jobName.fill = GridBagConstraints.HORIZONTAL;
		gbc_jobName.anchor = GridBagConstraints.WEST;
		gbc_jobName.insets = new Insets(0, 0, 5, 5);
		gbc_jobName.gridx = 2;
		gbc_jobName.gridy = 1;
		add(jobName, gbc_jobName);
		jobName.setColumns(10);
		
		JLabel lblNewLabel_2 = new JLabel("Job Description:");
		lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 15));
		GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
		gbc_lblNewLabel_2.anchor = GridBagConstraints.NORTHEAST;
		gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_2.gridx = 1;
		gbc_lblNewLabel_2.gridy = 2;
		add(lblNewLabel_2, gbc_lblNewLabel_2);
		GridBagConstraints gbc_jobDesc = new GridBagConstraints();
		gbc_jobDesc.insets = new Insets(0, 0, 5, 5);
		gbc_jobDesc.fill = GridBagConstraints.HORIZONTAL;
		gbc_jobDesc.gridx = 2;
		gbc_jobDesc.gridy = 2;
		add(getJobDesc(), gbc_jobDesc);
		
		JLabel lblEmployerId = new JLabel("Employer ID:");
		lblEmployerId.setFont(new Font("Tahoma", Font.PLAIN, 15));
		GridBagConstraints gbc_lblEmployerId = new GridBagConstraints();
		gbc_lblEmployerId.anchor = GridBagConstraints.EAST;
		gbc_lblEmployerId.fill = GridBagConstraints.VERTICAL;
		gbc_lblEmployerId.insets = new Insets(0, 0, 5, 5);
		gbc_lblEmployerId.gridx = 1;
		gbc_lblEmployerId.gridy = 3;
		add(lblEmployerId, gbc_lblEmployerId);
		GridBagConstraints gbc_employerID = new GridBagConstraints();
		gbc_employerID.insets = new Insets(0, 0, 5, 5);
		gbc_employerID.fill = GridBagConstraints.HORIZONTAL;
		gbc_employerID.gridx = 2;
		gbc_employerID.gridy = 3;
		add(getEmployerID(), gbc_employerID);
		
		JLabel lblHighestEducationAchievement = new JLabel("Highest Education Achievement:");
		lblHighestEducationAchievement.setFont(new Font("Tahoma", Font.PLAIN, 15));
		GridBagConstraints gbc_lblHighestEducationAchievement = new GridBagConstraints();
		gbc_lblHighestEducationAchievement.anchor = GridBagConstraints.NORTHEAST;
		gbc_lblHighestEducationAchievement.insets = new Insets(0, 0, 5, 5);
		gbc_lblHighestEducationAchievement.gridwidth = 2;
		gbc_lblHighestEducationAchievement.gridx = 0;
		gbc_lblHighestEducationAchievement.gridy = 4;
		add(lblHighestEducationAchievement, gbc_lblHighestEducationAchievement);
		GridBagConstraints gbc_edu_comboBox = new GridBagConstraints();
		gbc_edu_comboBox.anchor = GridBagConstraints.SOUTH;
		gbc_edu_comboBox.fill = GridBagConstraints.HORIZONTAL;
		gbc_edu_comboBox.insets = new Insets(0, 0, 5, 5);
		gbc_edu_comboBox.gridx = 2;
		gbc_edu_comboBox.gridy = 4;
		add(getEdu_comboBox(), gbc_edu_comboBox);
		GridBagConstraints gbc_lblSalary = new GridBagConstraints();
		gbc_lblSalary.anchor = GridBagConstraints.EAST;
		gbc_lblSalary.fill = GridBagConstraints.VERTICAL;
		gbc_lblSalary.insets = new Insets(0, 0, 5, 5);
		gbc_lblSalary.gridx = 1;
		gbc_lblSalary.gridy = 5;
		add(getLblSalary(), gbc_lblSalary);
		GridBagConstraints gbc_salarySpinner = new GridBagConstraints();
		gbc_salarySpinner.anchor = GridBagConstraints.WEST;
		gbc_salarySpinner.insets = new Insets(0, 0, 5, 5);
		gbc_salarySpinner.gridx = 2;
		gbc_salarySpinner.gridy = 5;
		add(getSalarySpinner(), gbc_salarySpinner);
		GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
		gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_3.gridx = 1;
		gbc_lblNewLabel_3.gridy = 6;
		add(getLblNewLabel_3(), gbc_lblNewLabel_3);
		GridBagConstraints gbc_noOfSlots = new GridBagConstraints();
		gbc_noOfSlots.anchor = GridBagConstraints.WEST;
		gbc_noOfSlots.insets = new Insets(0, 0, 5, 5);
		gbc_noOfSlots.gridx = 2;
		gbc_noOfSlots.gridy = 6;
		add(getNoOfSlots(), gbc_noOfSlots);
		GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints();
		gbc_lblNewLabel_4.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_4.gridx = 1;
		gbc_lblNewLabel_4.gridy = 7;
		add(getLblNewLabel_4(), gbc_lblNewLabel_4);
		GridBagConstraints gbc_category_Combo = new GridBagConstraints();
		gbc_category_Combo.insets = new Insets(0, 0, 5, 5);
		gbc_category_Combo.fill = GridBagConstraints.HORIZONTAL;
		gbc_category_Combo.gridx = 2;
		gbc_category_Combo.gridy = 7;
		add(getCategory_Combo(), gbc_category_Combo);
		GridBagConstraints gbc_lblJobStatus = new GridBagConstraints();
		gbc_lblJobStatus.anchor = GridBagConstraints.EAST;
		gbc_lblJobStatus.insets = new Insets(0, 0, 5, 5);
		gbc_lblJobStatus.gridx = 1;
		gbc_lblJobStatus.gridy = 8;
		add(getLblJobStatus(), gbc_lblJobStatus);
		GridBagConstraints gbc_statusCombo = new GridBagConstraints();
		gbc_statusCombo.insets = new Insets(0, 0, 5, 5);
		gbc_statusCombo.fill = GridBagConstraints.HORIZONTAL;
		gbc_statusCombo.gridx = 2;
		gbc_statusCombo.gridy = 8;
		add(getStatusCombo(), gbc_statusCombo);
		GridBagConstraints gbc_label = new GridBagConstraints();
		gbc_label.anchor = GridBagConstraints.EAST;
		gbc_label.insets = new Insets(0, 0, 5, 5);
		gbc_label.gridx = 1;
		gbc_label.gridy = 9;
		add(getLabel(), gbc_label);
		GridBagConstraints gbc_job_Submit = new GridBagConstraints();
		gbc_job_Submit.insets = new Insets(0, 0, 5, 5);
		gbc_job_Submit.gridx = 1;
		gbc_job_Submit.gridy = 10;
		add(getJob_Submit(), gbc_job_Submit);
		GridBagConstraints gbc_job_Cancel = new GridBagConstraints();
		gbc_job_Cancel.insets = new Insets(0, 0, 5, 5);
		gbc_job_Cancel.gridx = 2;
		gbc_job_Cancel.gridy = 10;
		add(getJob_Cancel(), gbc_job_Cancel);
	}
	public JComboBox getEdu_comboBox() {
		if (edu_comboBox == null) {
			edu_comboBox = new JComboBox();
			edu_comboBox.setFont(new Font("Tahoma", Font.PLAIN, 15));
			edu_comboBox.setModel(new DefaultComboBoxModel(new String[] {"PSLE", "N Levels ", "O Levels ", "Tertiary Diploma ", "Masters ", "PHD"}));
		}
		return edu_comboBox;
	}
	public JLabel getLblSalary() {
		if (lblSalary == null) {
			lblSalary = new JLabel("Salary:");
			lblSalary.setFont(new Font("Tahoma", Font.PLAIN, 15));
		}
		return lblSalary;
	}
	public JLabel getLblNewLabel_3() {
		if (lblNewLabel_3 == null) {
			lblNewLabel_3 = new JLabel("No. of Slots:");
			lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 15));
		}
		return lblNewLabel_3;
	}
	public JLabel getLblNewLabel_4() {
		if (lblNewLabel_4 == null) {
			lblNewLabel_4 = new JLabel("Category:");
			lblNewLabel_4.setFont(new Font("Tahoma", Font.PLAIN, 15));
		}
		return lblNewLabel_4;
	}
	public JComboBox getCategory_Combo() {
		if (category_Combo == null) {
			category_Combo = new JComboBox();
			category_Combo.setFont(new Font("Tahoma", Font.PLAIN, 15));
			category_Combo.setModel(new DefaultComboBoxModel(new String[] {"Accounting ", "Admin & Clerical ", "Automotive ", "Banking ", "Biotech ", "Broadcast - Journalism ", "Business Development ", "Construction ", "Consultant ", "Customer Service ", "Design ", "Distribution - Shipping ", "Education - Teaching ", "Engineering ", "Entry Level - New Grad ", "Executive ", "Facilities ", "Finance ", "Franchise", "General Business ", "General Labor ", "Government ", "Grocery ", "Health Care ", "Hotel - Hospitality ", "Human Resources ", "Information Technology ", "Installation - Maint - Repair ", "Insurance ", "Inventory ", "Legal ", "Legal Admin ", "Management ", "Manufacturing ", "Marketing ", "Media - Journalism - Newspaper ", "Nonprofit - Social Services  ", "Nurse", "Pharmaceutical ", "Professional Services ", "Purchasing - Procurement ", "QA - Quality Control ", "Real Estate ", "Research ", "Restaturant - Food Service ", "Retail ", "Sales ", "Science ", "Skilled Labor - Trades ", "Strategy - Planning ", "Supply CHain ", "Telecommunications ", "Training", "Transportation ", "Warehouse"}));
		}
		return category_Combo;
	}
	public JLabel getLabel() {
		if (label == null) {
			label = new JLabel("");
		}
		return label;
	}
	public JLabel getLblJobStatus() {
		if (lblJobStatus == null) {
			lblJobStatus = new JLabel("Job Status:");
			lblJobStatus.setFont(new Font("Tahoma", Font.PLAIN, 15));
		}
		return lblJobStatus;
	}
	public JComboBox getStatusCombo() {
		if (statusCombo == null) {
			statusCombo = new JComboBox();
			statusCombo.setFont(new Font("Tahoma", Font.PLAIN, 15));
			statusCombo.setModel(new DefaultComboBoxModel(new String[] {"Available ", "Unavilable"}));
		}
		return statusCombo;
	}
	public JButton getJob_Submit() {
		if (job_Submit == null) {
			job_Submit = new JButton("Submit"); 
			final Job_RegistrationForm panel = this;
			job_Submit.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) { 
					if (CommonControls.validatePanelFields(panel) == true){
					Controller.createJob();
					JOptionPane.showMessageDialog(null, "Registration Success"); 
					}
				}
			});
			job_Submit.setFont(new Font("Tahoma", Font.BOLD, 15));
		}

		return job_Submit; 
		

	}
	public JButton getJob_Cancel() {
		if (job_Cancel == null) {
			job_Cancel = new JButton("Cancel");
			job_Cancel.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
				
				}
			});
			job_Cancel.setFont(new Font("Tahoma", Font.BOLD, 15));
		}
		return job_Cancel;
	}
	public JTextField getJobName() {
		// TODO Auto-generated method stub
		return jobName;
	}
	public JTextField getJobDesc() {
		if (jobDesc == null) {
			jobDesc = new JTextField();
			jobDesc.setColumns(10);
		}
		return jobDesc;
	}

	public JTextField getEmployerID() {
		if (employerID == null) {
			employerID = new JTextField();
			employerID.setColumns(10);
		}
		return employerID;
	}
	public JSpinner getSalarySpinner() {
		if (salarySpinner == null) {
			salarySpinner = new JSpinner();
			salarySpinner.setModel(new SpinnerNumberModel(0.0, null, 2500.0, 5.0));
		}
		return salarySpinner;
	}
	public JSpinner getNoOfSlots() {
		if (noOfSlots == null) {
			noOfSlots = new JSpinner();
			noOfSlots.setModel(new SpinnerNumberModel(new Integer(1), new Integer(1), null, new Integer(1)));
		}
		return noOfSlots;
	}
}
